﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Data.SqlTypes;
using System.Web.Mvc;
using IBS.Model;

namespace CommonApp.Models
{

    public class UserRequest
    {
        public int Id { get; set; }

        [Required]
        [Display(Name = "Name")]
        [StringLength(50, ErrorMessage = "The {0} must be at most {1} characters long.")]
        [RegularExpression(@"^[A-Z][a-zA-Z]+$", ErrorMessage = "{0} should contain letters, starting with capital one")]
        public string FirstName { get; set; }

        [Required]
        [Display(Name = "Surname")]
        [StringLength(50, ErrorMessage = "The {0} must be at most {1} characters long.")]
        [RegularExpression(@"^[A-Z][a-zA-Z]+$", ErrorMessage = "{0} should contain letters, starting with capital one")]
        public string LastName { get; set; }

        [Required]
        [Display(Name = "Passport Number")]
        [RegularExpression("^[0-9]{7}$", ErrorMessage = "Passport number must be 7 digits long.")]
        public int PassportNumber { get; set; }

        [Required]
        [Display(Name = "Passport Series")]
        [RegularExpression("^[A-Z]{2}$", ErrorMessage = "Passport series must be 2 capital letters.")]
        public string PassportSeries { get; set; }

        [Required]
        [Display(Name = "Email address")]
        [DataType(DataType.EmailAddress)]
        [StringLength(256, ErrorMessage = "The {0} must be at most {1} characters long.")]
        [RegularExpression(@"\w+@[a-zA-Z0-9\-]+\.([a-zA-Z]{2,4}|[0-9]{1,3})", ErrorMessage = "Invalid Email format")]
        public string Email { get; set; }

        [Required]
        [Display(Name = "Password")]
        [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
        [DataType(DataType.Password)]
        public string Password { get; set; }

        [DataType(DataType.Password)]
        [Display(Name = "Confirm password")]
        [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
        public string ConfirmPassword { get; set; }

        [Display(Name="Submit Date")]
        public virtual DateTime SubmitDate { get; set; }

        [Required]
        [Display(Name = "Date Of Birth")]
        [DataType(DataType.Date)]
        [DateRangeValidation(MinYears = -200, MaxYears = 0, ErrorMessage = "The {0} is invalid")]
        public DateTime? DateOfBirth { get; set; }

        [Required]
        [Display(Name = "Invent login")]
        [StringLength(50, ErrorMessage = "The {0} must be at most {1} characters long.")]
        [RegularExpression(@"[a-zA-Z]\w+", ErrorMessage = "{0} should contain letters or digits only. The first symbol has to be letter.")]
        public string Login { get; set; }

        public RequestStatus Status { get; set; }

        public int? ClientId { get; set; }
    }

    public class DetailUserRequest
    {
        public UserRequest RequestInfo { get; set; }
        public ClientModel ClientInfo { get; set; }
    }
}